/*
 * Copyright (c) 2009 Johnny Mast
 * 
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

#import <Foundation/Foundation.h>
#import "GameEngine.h"


@class Image;
@class Resources;


@interface SpriteSheet : NSObject {
	Image *image;
	UIImage* SpriteSheetImage;
	GLuint horizontal;
	GLuint vertical;
	
	GLuint SpriteWidth;
	GLuint SpriteHeight;
	GLuint SpriteScale;
	GLuint SpriteSpacing;
	
	// Texture coordinate array
    Quad2f *cachedTextureCoordinates;
	Resources* Resource;
	
}

@property(nonatomic, retain) Image* image;
@property(nonatomic, readonly) Quad2f *cachedTextureCoordinates;;
@property(nonatomic, readonly) GLuint SpriteScale;
@property(nonatomic, readonly) GLuint SpriteWidth;
@property(nonatomic, readonly) GLuint SpriteHeight;
@property(nonatomic, readonly) GLuint SpriteSpacing;
@property(nonatomic, retain)   UIImage* SpriteSheetImage;
@property(nonatomic, readonly) GLuint horizontal;
@property(nonatomic, readonly) GLuint vertical;
@property(nonatomic, readonly) Resources* Resource;
-(id)initWithSpriteSheet:(NSString*)sheetname;
-(id)initWithImageNamed:(NSString*)sheetname spriteWidth:(GLuint)width spriteHeight:(GLuint)height spacing:(GLuint)imageSpacing imageScale:(GLuint)imageScale;

-(Quad2f)getTextureCoordsForSpriteAtX:(GLuint)x y:(GLuint)y;
-(Image*)getSpriteAtX:(GLuint)x y:(GLuint)y;
-(void)renderSpriteAtX:(GLuint)x y:(GLuint)y point:(CGPoint)aPoint centerOfImage:(BOOL)aCenter;
-(CGPoint)getOffsetForSpriteAtX:(int)x y:(int)y;

-(void)setHeight:(GLuint)spriteheight;
-(void)setWidth:(GLuint)spritewidth;
-(void)setSpacing:(GLuint)spritespacing;
-(void)setScale:(GLuint)spritescale;

- (Image*)getSpriteAtX:(GLuint)x y:(GLuint)y;
/*
-(Image * )getImageAtRow:(GLuint)row col:(GLuint)col;
-(Image * )getSpriteAtRow:(GLuint)row col:(GLuint)col;
*/
-(Image * )getImageAtRow:(float)row col:(float)col;
-(Quad2f*)getVerticesForSpriteAtX:(GLuint)x y:(GLuint)y point:(CGPoint)aPoint centerOfImage:(BOOL)aCenter;
@end

